<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table {
            width: 800px;
            text-align: center;
            margin: 100px auto;
        }

        td,
        th {
            border: 1px solid #000;
        }
    </style>
</head>

<body>
    <div id="app">
        <table>
            <tr>
                <th>苹果10￥/斤,折扣 8折</th>
            </tr>
            <tr>
                <td>请输入你要购买的斤数<input v-model="jinshu" type="text"></td>
            </tr>
            <tr>
                <td><button @click="fun">结账买单</button></td>
            </tr>
            <tr>
                <td>结账单：总价：{{zongjia}}元 折后价：{{zhehou}}元 省了：{{jiesheng}}元</td>
            </tr>
        </table>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>

    <script>
        const app = new Vue({
            el: '#app',
            data: {
                jinshu: 0,
                zongjia: 0,
                zhehou: 0,
                jiesheng: 0
            },
            methods: {
                fun() {
                    this.zongjia = this.jinshu * 10;
                    this.zhehou = this.zongjia * 0.8;
                    this.jiesheng = this.zongjia - this.zhehou;
                }
            }
        });
    </script>
</body>

</html>